# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -mtriple=amdgcn-amd-amdhsa -run-pass=amdgpu-postlegalizer-combiner -verify-machineinstrs %s -o - | FileCheck %s

---
name: test_fcanonicalize
tracksRegLiveness: true
legalized: true
body: |
  bb.0:
    liveins: $vgpr0

    ; CHECK-LABEL: name: test_fcanonicalize
    ; CHECK: liveins: $vgpr0
    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
    ; CHECK: [[FCANONICALIZE:%[0-9]+]]:_(s32) = G_FCANONICALIZE [[COPY]]
    ; CHECK: $vgpr0 = COPY [[FCANONICALIZE]](s32)
    %0:_(s32) = COPY $vgpr0
    %1:_(s32) = G_FCANONICALIZE %0
    %2:_(s32) = G_FCANONICALIZE %1
    $vgpr0 = COPY %2(s32)
...

---
name: test_fconstant
tracksRegLiveness: true
legalized: true
body: |
  bb.0:

    ; CHECK-LABEL: name: test_fconstant
    ; CHECK: [[C:%[0-9]+]]:_(s32) = G_FCONSTANT float 1.000000e+10
    ; CHECK: $vgpr0 = COPY [[C]](s32)
    %0:_(s32) = G_FCONSTANT float 1.0e10
    %1:_(s32) = G_FCANONICALIZE %0
    $vgpr0 = COPY %1(s32)
...

---
name: test_denormal_fconstant
tracksRegLiveness: true
legalized: true
machineFunctionInfo:
  mode:
    fp64-fp16-output-denormals: false
    fp64-fp16-input-denormals: false
body: |
  bb.0:

    ; CHECK-LABEL: name: test_denormal_fconstant
    ; CHECK: [[C:%[0-9]+]]:_(s64) = G_FCONSTANT double 1.618950e-319
    ; CHECK: [[FCANONICALIZE:%[0-9]+]]:_(s64) = G_FCANONICALIZE [[C]]
    ; CHECK: $vgpr0_vgpr1 = COPY [[FCANONICALIZE]](s64)
    %0:_(s64) = G_FCONSTANT double 0x0000000000008000
    %1:_(s64) = G_FCANONICALIZE %0
    $vgpr0_vgpr1 = COPY %1(s64)
...

---
name: test_fminnum_with_fminnum_argument_s32_ieee_mode_on
tracksRegLiveness: true
legalized: true
machineFunctionInfo:
  mode:
    ieee: true
body: |
  bb.0:
    liveins: $vgpr0, $vgpr1, $vgpr2

    ; CHECK-LABEL: name: test_fminnum_with_fminnum_argument_s32_ieee_mode_on
    ; CHECK: liveins: $vgpr0, $vgpr1, $vgpr2
    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
    ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY $vgpr1
    ; CHECK: [[FCANONICALIZE:%[0-9]+]]:_(s32) = G_FCANONICALIZE [[COPY]]
    ; CHECK: [[FCANONICALIZE1:%[0-9]+]]:_(s32) = G_FCANONICALIZE [[COPY1]]
    ; CHECK: [[FMINNUM_IEEE:%[0-9]+]]:_(s32) = G_FMINNUM_IEEE [[FCANONICALIZE]], [[FCANONICALIZE1]]
    ; CHECK: [[COPY2:%[0-9]+]]:_(s32) = COPY $vgpr2
    ; CHECK: [[FCANONICALIZE2:%[0-9]+]]:_(s32) = G_FCANONICALIZE [[COPY2]]
    ; CHECK: [[FMINNUM_IEEE1:%[0-9]+]]:_(s32) = G_FMINNUM_IEEE [[FMINNUM_IEEE]], [[FCANONICALIZE2]]
    ; CHECK: $vgpr0 = COPY [[FMINNUM_IEEE1]](s32)
    %0:_(s32) = COPY $vgpr0
    %1:_(s32) = COPY $vgpr1
    %7:_(s32) = G_FCANONICALIZE %0
    %8:_(s32) = G_FCANONICALIZE %1
    %2:_(s32) = G_FMINNUM_IEEE %7, %8
    %3:_(s32) = COPY $vgpr2
    %5:_(s32) = G_FCANONICALIZE %2
    %6:_(s32) = G_FCANONICALIZE %3
    %4:_(s32) = G_FMINNUM_IEEE %5, %6
    $vgpr0 = COPY %4(s32)
...

---
name: test_fminnum_with_fmaxnum_argument_s32_ieee_mode_on
tracksRegLiveness: true
legalized: true
machineFunctionInfo:
  mode:
    ieee: true
body: |
  bb.0:
    liveins: $vgpr0, $vgpr1, $vgpr2

    ; CHECK-LABEL: name: test_fminnum_with_fmaxnum_argument_s32_ieee_mode_on
    ; CHECK: liveins: $vgpr0, $vgpr1, $vgpr2
    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
    ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY $vgpr1
    ; CHECK: [[FCANONICALIZE:%[0-9]+]]:_(s32) = G_FCANONICALIZE [[COPY]]
    ; CHECK: [[FCANONICALIZE1:%[0-9]+]]:_(s32) = G_FCANONICALIZE [[COPY1]]
    ; CHECK: [[FMAXNUM_IEEE:%[0-9]+]]:_(s32) = G_FMAXNUM_IEEE [[FCANONICALIZE]], [[FCANONICALIZE1]]
    ; CHECK: [[COPY2:%[0-9]+]]:_(s32) = COPY $vgpr2
    ; CHECK: [[FCANONICALIZE2:%[0-9]+]]:_(s32) = G_FCANONICALIZE [[COPY2]]
    ; CHECK: [[FMINNUM_IEEE:%[0-9]+]]:_(s32) = G_FMINNUM_IEEE [[FMAXNUM_IEEE]], [[FCANONICALIZE2]]
    ; CHECK: $vgpr0 = COPY [[FMINNUM_IEEE]](s32)
    %0:_(s32) = COPY $vgpr0
    %1:_(s32) = COPY $vgpr1
    %7:_(s32) = G_FCANONICALIZE %0
    %8:_(s32) = G_FCANONICALIZE %1
    %2:_(s32) = G_FMAXNUM_IEEE %7, %8
    %3:_(s32) = COPY $vgpr2
    %5:_(s32) = G_FCANONICALIZE %2
    %6:_(s32) = G_FCANONICALIZE %3
    %4:_(s32) = G_FMINNUM_IEEE %5, %6
    $vgpr0 = COPY %4(s32)
...

---
name: test_fmaxnum_with_fmaxnum_argument_s32_ieee_mode_on
tracksRegLiveness: true
legalized: true
machineFunctionInfo:
  mode:
    ieee: true
body: |
  bb.0:
    liveins: $vgpr0, $vgpr1, $vgpr2

    ; CHECK-LABEL: name: test_fmaxnum_with_fmaxnum_argument_s32_ieee_mode_on
    ; CHECK: liveins: $vgpr0, $vgpr1, $vgpr2
    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
    ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY $vgpr1
    ; CHECK: [[FCANONICALIZE:%[0-9]+]]:_(s32) = G_FCANONICALIZE [[COPY]]
    ; CHECK: [[FCANONICALIZE1:%[0-9]+]]:_(s32) = G_FCANONICALIZE [[COPY1]]
    ; CHECK: [[FMAXNUM_IEEE:%[0-9]+]]:_(s32) = G_FMAXNUM_IEEE [[FCANONICALIZE]], [[FCANONICALIZE1]]
    ; CHECK: [[COPY2:%[0-9]+]]:_(s32) = COPY $vgpr2
    ; CHECK: [[FCANONICALIZE2:%[0-9]+]]:_(s32) = G_FCANONICALIZE [[COPY2]]
    ; CHECK: [[FMAXNUM_IEEE1:%[0-9]+]]:_(s32) = G_FMAXNUM_IEEE [[FMAXNUM_IEEE]], [[FCANONICALIZE2]]
    ; CHECK: $vgpr0 = COPY [[FMAXNUM_IEEE1]](s32)
    %0:_(s32) = COPY $vgpr0
    %1:_(s32) = COPY $vgpr1
    %7:_(s32) = G_FCANONICALIZE %0
    %8:_(s32) = G_FCANONICALIZE %1
    %2:_(s32) = G_FMAXNUM_IEEE %7, %8
    %3:_(s32) = COPY $vgpr2
    %5:_(s32) = G_FCANONICALIZE %2
    %6:_(s32) = G_FCANONICALIZE %3
    %4:_(s32) = G_FMAXNUM_IEEE %5, %6
    $vgpr0 = COPY %4(s32)
...

---
name: test_fmaxnum_with_fminnum_argument_s32_ieee_mode_on
tracksRegLiveness: true
legalized: true
machineFunctionInfo:
  mode:
    ieee: true
body: |
  bb.0:
    liveins: $vgpr0, $vgpr1, $vgpr2

    ; CHECK-LABEL: name: test_fmaxnum_with_fminnum_argument_s32_ieee_mode_on
    ; CHECK: liveins: $vgpr0, $vgpr1, $vgpr2
    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
    ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY $vgpr1
    ; CHECK: [[FCANONICALIZE:%[0-9]+]]:_(s32) = G_FCANONICALIZE [[COPY]]
    ; CHECK: [[FCANONICALIZE1:%[0-9]+]]:_(s32) = G_FCANONICALIZE [[COPY1]]
    ; CHECK: [[FMINNUM_IEEE:%[0-9]+]]:_(s32) = G_FMINNUM_IEEE [[FCANONICALIZE]], [[FCANONICALIZE1]]
    ; CHECK: [[COPY2:%[0-9]+]]:_(s32) = COPY $vgpr2
    ; CHECK: [[FCANONICALIZE2:%[0-9]+]]:_(s32) = G_FCANONICALIZE [[COPY2]]
    ; CHECK: [[FMAXNUM_IEEE:%[0-9]+]]:_(s32) = G_FMAXNUM_IEEE [[FMINNUM_IEEE]], [[FCANONICALIZE2]]
    ; CHECK: $vgpr0 = COPY [[FMAXNUM_IEEE]](s32)
    %0:_(s32) = COPY $vgpr0
    %1:_(s32) = COPY $vgpr1
    %7:_(s32) = G_FCANONICALIZE %0
    %8:_(s32) = G_FCANONICALIZE %1
    %2:_(s32) = G_FMINNUM_IEEE %7, %8
    %3:_(s32) = COPY $vgpr2
    %5:_(s32) = G_FCANONICALIZE %2
    %6:_(s32) = G_FCANONICALIZE %3
    %4:_(s32) = G_FMAXNUM_IEEE %5, %6
    $vgpr0 = COPY %4(s32)
...

---
name: test_multiple_uses
tracksRegLiveness: true
legalized: true
machineFunctionInfo:
  mode:
    ieee: true
body: |
  bb.0:
    liveins: $vgpr0, $vgpr1

    ; CHECK-LABEL: name: test_multiple_uses
    ; CHECK: liveins: $vgpr0, $vgpr1
    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
    ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY $vgpr1
    ; CHECK: [[FCANONICALIZE:%[0-9]+]]:_(s32) = G_FCANONICALIZE [[COPY]]
    ; CHECK: [[FCANONICALIZE1:%[0-9]+]]:_(s32) = G_FCANONICALIZE [[COPY1]]
    ; CHECK: [[FMINNUM_IEEE:%[0-9]+]]:_(s32) = G_FMINNUM_IEEE [[FCANONICALIZE]], [[FCANONICALIZE1]]
    ; CHECK: [[FMAXNUM_IEEE:%[0-9]+]]:_(s32) = G_FMAXNUM_IEEE [[FMINNUM_IEEE]], [[FMINNUM_IEEE]]
    ; CHECK: $vgpr0 = COPY [[FMAXNUM_IEEE]](s32)
    %0:_(s32) = COPY $vgpr0
    %1:_(s32) = COPY $vgpr1
    %6:_(s32) = G_FCANONICALIZE %0
    %7:_(s32) = G_FCANONICALIZE %1
    %2:_(s32) = G_FMINNUM_IEEE %6, %7
    %4:_(s32) = G_FCANONICALIZE %2
    %5:_(s32) = G_FCANONICALIZE %2
    %3:_(s32) = G_FMAXNUM_IEEE %4, %5
    $vgpr0 = COPY %3(s32)
...
